﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using WebApplication1.bll;

namespace WebApplication1.dao
{
    public class conexaopagelogin : Ilogin
    {
        public int conexaologin(string email, string senha)
        {
            String conexString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["wallet"].ConnectionString;
            System.Data.SqlClient.SqlConnection conexao = new System.Data.SqlClient.SqlConnection(conexString);
            System.Data.SqlClient.SqlCommand comando = new System.Data.SqlClient.SqlCommand();
            comando.Connection = conexao;
            comando.CommandType = System.Data.CommandType.Text;
            comando.CommandText = "select count(id_cadastro) from cadastro where email='" + email + "' and senha='" + senha + "' ";
            conexao.Open();
            int number = (int)comando.ExecuteScalar();
            conexao.Close();
            if (number == 1)
            {
                comando.CommandType = System.Data.CommandType.Text;
                comando.CommandText = "select id_cadastro from cadastro where email='" + email + "' and senha ='" + senha + "'";
                conexao.Open();
                number = (int)comando.ExecuteScalar();
                conexao.Close();

            }
            return number;


        }


    }

}